package com.lefu.es.util;

import android.app.Activity;
import android.content.Context;
import android.support.v4.content.ContextCompat;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.lefu.es.constant.UtilConstants;
import com.wellness.scale.R;

/**
 * 控制笑脸在水平上的偏移
 * Created by lenovo on 2017/1/11.
 */

public class MoveView {

    /**
     * * 体重部分
     *
     * @param activity  当前Activity
     * @param view      笑脸图标父级
     * @param imageView 笑脸图标
     * @param textView1 从左到右第一个分割线
     * @param textView2 从左到右第二个分割线
     * @param textView3 是否标准
     * @param gender    性别：0男，1女
     * @param height    身高
     * @param weight    体重
     */
    private static Context context;
    private static int roundWidth;//太阳的半径

    private static String TAG = "MoveView";

    public static void weight(Activity activity, View view, ImageView imageView, TextView textView1, TextView textView2, TextView textView3, int gender, float height, float weight, String danwei) {
        roundWidth = DisplayUtil.dip2px(activity, 15);
        roundWidth = (roundWidth / 2);
        int margWidth = DisplayUtil.dip2px(activity, 10);
        LogUtils.d(TAG, "太阳的半径：" + roundWidth + "px");
        LogUtils.d(TAG, "margWidth：" + margWidth + "px");
        int d = DisplayUtil.dip2px(activity, 10f);
        int screenwidth = activity.getWindowManager().getDefaultDisplay().getWidth();
        int marg = DisplayUtil.dip2px(activity, 20f);
        screenwidth = screenwidth - marg;
        LogUtils.d(TAG, "屏幕宽度" + screenwidth);

        // 标准体重
        float standard_weight;
        // 从左到右第一个分割线
        float critical_point1;
        // 从左到右第二个分割线
        float critical_point2;
        // 终点分割线
        float critical_point3;
        // 笑脸偏移量
        int deviation = 0;
        // 屏幕宽度

        if (gender == 1) {
            standard_weight = (height - 80) * 0.7f;
        } else {
            standard_weight = (height - 70) * 0.6f;
        }
        critical_point1 = standard_weight - standard_weight * 0.1f;
        critical_point2 = standard_weight + standard_weight * 0.1f;
        critical_point3 = 220;
        LogUtils.d(TAG, "critical_point1：" + critical_point1);
        LogUtils.d(TAG, "critical_point2：" + critical_point2);
        LogUtils.d(TAG, "critical_point3：" + critical_point3);
        if (weight < critical_point1) {
            deviation = (int) (screenwidth * 0.25 * (weight / critical_point1));
            LogUtils.d(TAG, "==============pindLeft1:" + deviation);
            LogUtils.d(TAG, "==============pindLeft:" + deviation);
            imageView.setImageDrawable(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.sunface));
            textView3.setText(R.string.bar_piandi_title);//偏低
            textView3.setBackground(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.orange_bg));
        } else if (weight >= critical_point1 && weight < critical_point2) {
            imageView.setImageDrawable(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.sunface));
            deviation = (int) (screenwidth * 0.25 + (weight - critical_point1) / (critical_point2 - critical_point1) * screenwidth * 0.5);
            textView3.setText(R.string.bar_biaozhun_title);//标准
            textView3.setBackground(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.grade_bg));
        } else if (weight >= critical_point2) {

            imageView.setImageDrawable(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.sunface));
            double ls = (screenwidth * 0.25) / (critical_point3 - critical_point2);
            deviation = (int) ((int) (screenwidth * 0.75) + (ls * (weight - critical_point2)));
            textView3.setText(R.string.bar_piangao_title);//偏高
            textView3.setBackground(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.red_color_bg));
        }
        if (danwei.equals(UtilConstants.UNIT_LB) || danwei.equals(UtilConstants.UNIT_FATLB) || danwei.equals(UtilConstants.UNIT_ST)) {
            textView1.setText(UtilTooth.kgToLB_ForFatScale(critical_point1) + "lb");
            textView2.setText(UtilTooth.kgToLB_ForFatScale(critical_point2) + "lb");
        } else {
            textView1.setText(MyUtil.onePoint(critical_point1) + "kg");
            textView2.setText(MyUtil.onePoint(critical_point2) + "kg");
        }
        if (deviation > roundWidth) {
            deviation = (deviation - roundWidth);
        }
        if (deviation >= (screenwidth - roundWidth * 2)) {
            deviation = (screenwidth - roundWidth * 2);
        }
        LogUtils.d(TAG, "deviation:" + deviation + "d:" + d);
        view.setPadding(deviation, 0, 0, 0);
    }

    public static String weightString(int gender, float height, float weight, Context context) {
        MoveView.context = context;
        // 标准体重
        float standard_weight;
        // 从左到右第一个分割线
        float critical_point1;
        // 从左到右第二个分割线
        float critical_point2;
        // 终点分割线
        //float critical_point3;

        if (gender == 1) {
            standard_weight = (height - 80) * 0.7f;
        } else {
            standard_weight = (height - 70) * 0.6f;
        }
        critical_point1 = standard_weight - standard_weight * 0.1f;
        critical_point2 = standard_weight + standard_weight * 0.1f;
        //critical_point3 = standard_weight + standard_weight * 0.2f;

        if (weight < critical_point1) {
            return context.getString(R.string.bar_piandi_title);//偏低
        } else if (weight >= critical_point1 && weight < critical_point2) {
            return context.getString(R.string.bar_biaozhun_title);//标准
        } else {
            return context.getString(R.string.bar_piangao_title);//偏高
        }

    }

    public static int weightInt(int gender, float height, float weight) {
        // 标准体重
        float standard_weight;
        // 从左到右第一个分割线
        float critical_point1;
        // 从左到右第二个分割线
        float critical_point2;
        // 终点分割线
        //float critical_point3;

        if (gender == 1) {
            standard_weight = (height - 80) * 0.7f;
        } else {
            standard_weight = (height - 70) * 0.6f;
        }
        critical_point1 = standard_weight - standard_weight * 0.1f;
        critical_point2 = standard_weight + standard_weight * 0.1f;
        //critical_point3 = standard_weight + standard_weight * 0.2f;

        if (weight < critical_point1) {
            return 1;
        } else if (weight >= critical_point1 && weight < critical_point2) {
            return 2;
        } else {
            return 3;
        }

    }


    /**
     * 计算baby的体重标准
     *
     * @param gender
     * @param height
     * @param weight
     * @return
     */
    public static String babyWeightString(int age, int gender, float height, float weight ,Context context) {
        MoveView.context=context;
        // 标准体重
        float standard_weight;
        // 从左到右第一个分割线
        float critical_point1;
        // 从左到右第二个分割线
        float critical_point2;
        // 终点分割线
        //float critical_point3;

        if (age <= 5) {
            LogUtils.i("MoveView", "按小孩的标准计算");
            if (gender == 2) {
                switch (age) {
                    case 1:
                        if (weight < 8.5) {
                            return context.getString(R.string.bar_piandi_title);//偏低
                        } else if (weight > 10.6) {
                            return context.getString(R.string.bar_piangao_title);//偏高
                        } else {

                            return context.getString(R.string.bar_biaozhun_title);//标准
                        }
                    case 2:
                        if (weight < 10.6) {
                            return context.getString(R.string.bar_piandi_title);//偏低
                        } else if (weight > 13.2) {
                            return context.getString(R.string.bar_piangao_title);//偏高
                        } else {


                            return context.getString(R.string.bar_biaozhun_title);//标准
                        }
                    case 3:
                        if (weight < 13) {
                            return context.getString(R.string.bar_piandi_title);//偏低

                        } else if (weight > 16.4) {
                            return context.getString(R.string.bar_piangao_title);//偏高
                        } else {


                            return context.getString(R.string.bar_biaozhun_title);//标准
                        }
                    case 4:
                        if (weight < 12.6) {
                            return context.getString(R.string.bar_piandi_title);//偏低

                        } else if (weight > 16.1) {
                            return context.getString(R.string.bar_piangao_title);//偏高

                        } else {

                            return context.getString(R.string.bar_biaozhun_title);//标准
                        }

                    case 5:
                        if (weight < 15.7) {
                            return context.getString(R.string.bar_piandi_title);//偏低
                        } else if (weight > 20.4) {
                            return context.getString(R.string.bar_piangao_title);//偏高
                        } else {

                            return context.getString(R.string.bar_biaozhun_title);//标准
                        }
                        default:
                }
                // standard_weight = (height - 80) * 0.7f;
            } else {
                LogUtils.i("MoveView", "==========女=============");
                switch (age) {
                    case 1:
                        if (weight < 9.1) {
                            return context.getString(R.string.bar_piandi_title);//偏低
                        } else if (weight > 11.3) {
                            return context.getString(R.string.bar_piangao_title);//偏高
                        } else {

                            return context.getString(R.string.bar_biaozhun_title);//标准
                        }
                    case 2:
                        if (weight < 11.2) {
                            return context.getString(R.string.bar_piandi_title);//偏低
                        } else if (weight > 14) {
                            return context.getString(R.string.bar_piangao_title);//偏高
                        } else {


                            return context.getString(R.string.bar_biaozhun_title);//标准
                        }
                    case 3:
                        if (weight < 13) {
                            return context.getString(R.string.bar_piandi_title);//偏低

                        } else if (weight > 16.4) {
                            return context.getString(R.string.bar_piangao_title);//偏高
                        } else {


                            return context.getString(R.string.bar_biaozhun_title);//标准
                        }
                    case 4:
                        if (weight < 14.8) {
                            return context.getString(R.string.bar_piandi_title);//偏低

                        } else if (weight > 18.7) {
                            return context.getString(R.string.bar_piangao_title);//偏高
                        } else {


                            return context.getString(R.string.bar_biaozhun_title);//标准
                        }

                    case 5:
                        if (weight < 16.6) {
                            return context.getString(R.string.bar_piandi_title);//偏低

                        } else if (weight > 21.1) {
                            return context.getString(R.string.bar_piangao_title);//偏高
                        } else {

                            return context.getString(R.string.bar_biaozhun_title);//标准
                        }
                        default:
                }
                // standard_weight = (height - 70) * 0.6f;
            }
           /* critical_point1 = standard_weight - standard_weight * 0.1f;
            critical_point2 = standard_weight + standard_weight * 0.1f;*/
            //critical_point3 = standard_weight + standard_weight * 0.2f;

           /* if (weight < critical_point1) {
                return context.getString(R.string.bar_piandi_title);//偏低
            } else if (weight >= critical_point1 && weight < critical_point2) {
                return context.getString(R.string.bar_biaozhun_title);//标准
            } else {
                return context.getString(R.string.bar_piangao_title);//偏高
            }*/

        } else {
            LogUtils.i("MoveView", "按小孩的标准计算");
            if (gender == 1) {
                //男
                standard_weight = (height - 80) * 0.7f;
            } else {
                //女
                standard_weight = (height - 70) * 0.6f;
            }
            critical_point1 = standard_weight - standard_weight * 0.1f;
            critical_point2 = standard_weight + standard_weight * 0.1f;
            //critical_point3 = standard_weight + standard_weight * 0.2f;

            if (weight < critical_point1) {
                return context.getString(R.string.bar_piandi_title);//偏低
            } else if (weight >= critical_point1 && weight < critical_point2) {
                return context.getString(R.string.bar_biaozhun_title);//标准
            } else {
                return context.getString(R.string.bar_piangao_title);//偏高
            }

        }
        return context.getString(R.string.bar_biaozhun_title);//标准
    }


    /**
     * 水分率
     *
     * @param activity     当前Activity
     * @param view         笑脸图标父级
     * @param imageView    笑脸图标
     * @param textView1    从左到右第一个分割线
     * @param textView2    从左到右第二个分割线
     * @param textView3    是否标准
     * @param gender       性别：0男，1女
     * @param waterPercent 当前用户水分率
     */
    public static void moisture(Activity activity, View view, ImageView imageView, TextView textView1, TextView textView2, TextView textView3, int gender, float waterPercent) {
        roundWidth = DisplayUtil.dip2px(activity, 15);
        roundWidth = (roundWidth / 2);
        int margWidth = DisplayUtil.dip2px(activity, 10);
        LogUtils.d(TAG, "太阳的半径：" + roundWidth + "px");
        LogUtils.d(TAG, "margWidth：" + margWidth + "px");
        int d = DisplayUtil.dip2px(activity, 10f);
        int screenwidth = activity.getWindowManager().getDefaultDisplay().getWidth();
        int marg = DisplayUtil.dip2px(activity, 20f);
        screenwidth = screenwidth - marg;
        LogUtils.d(TAG, "屏幕宽度" + screenwidth);

        // 从左到右第一个分割线
        double critical_point1;
        // 从左到右第二个分割线
        double critical_point2;
        // 终点分割线
        double critical_point3 = 100;
        // 笑脸偏移量
        int deviation = 0;
        if (gender == 1) {
            // 男
            critical_point1 = 55;
            critical_point2 = 65;
            critical_point3 = 100;
        } else {
            // 女
            critical_point1 = 45;
            critical_point2 = 60;
            critical_point3 = 100;
        }
        if (waterPercent <= critical_point1) {
            deviation = (int) (screenwidth * 0.25 * (waterPercent / critical_point1));
            imageView.setImageDrawable(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.sunface));
            textView3.setText(R.string.bar_buzu_title);//不足
            textView3.setBackground(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.red_color_bg));
        } else if (waterPercent > critical_point1 && waterPercent <= critical_point2) {
            imageView.setImageDrawable(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.sunface));
            deviation = (int) (screenwidth * 0.25 + (waterPercent - critical_point1) / (critical_point2 - critical_point1) * screenwidth * 0.5);
            textView3.setText(R.string.bar_biaozhun_title);//标准
            textView3.setBackground(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.green_light_color_bg));
        } else if (waterPercent > critical_point2) {
            imageView.setImageDrawable(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.sunface));
        /*    deviation = (int) (screenwidth * 0.75 + (waterPercent - critical_point2) / critical_point3 * screenwidth * 0.25);*/
            double ls = (screenwidth * 0.25) / (critical_point3 - critical_point2);
            deviation = (int) ((int) (screenwidth * 0.75) + (ls * (waterPercent - critical_point2)));
            textView3.setText(R.string.bar_you_title);//优
            textView3.setBackground(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.grade_bg));
        }
        textView1.setText(MyUtil.onePoint(critical_point1) + "%");
        textView2.setText(MyUtil.onePoint(critical_point2) + "%");

        if (deviation > roundWidth) {
            deviation = (deviation - roundWidth);
        }
        if (deviation >= (screenwidth - roundWidth * 2)) {
            deviation = (screenwidth - roundWidth * 2);
        }
        LogUtils.d(TAG, "deviation:" + deviation + "d:" + d);
        view.setPadding(deviation, 0, 0, 0);
    }

    public static String moistureString(int gender, float waterPercent,Context context) {
        MoveView.context=context;
        // 从左到右第一个分割线
        double critical_point1;
        // 从左到右第二个分割线
        double critical_point2;
        // 终点分割线
        double critical_point3 = 100;
        if (gender == 1) {
            // 男
            critical_point1 = 55;
            critical_point2 = 65;
        } else {
            // 女
            critical_point1 = 45;
            critical_point2 = 60;
        }
        if (waterPercent <= critical_point1) {
            return context.getString(R.string.bar_buzu_title);//不足
        } else if (waterPercent > critical_point1 && waterPercent <= critical_point2) {
            return context.getString(R.string.bar_biaozhun_title);//标准
        } else {
            return context.getString(R.string.bar_you_title);//优
        }

    }


    public static int moistureInt(int gender, float waterPercent) {
        // 从左到右第一个分割线
        double critical_point1;
        // 从左到右第二个分割线
        double critical_point2;
        // 终点分割线
        double critical_point3 = 100;
        if (gender == 1) {
            // 男
            critical_point1 = 55;
            critical_point2 = 65;
        } else {
            // 女
            critical_point1 = 45;
            critical_point2 = 60;
        }
        if (waterPercent <= critical_point1) {
            return 1;//不足
        } else if (waterPercent > critical_point1 && waterPercent <= critical_point2) {
            return 2;//标准
        } else {
            return 3;//优
        }

    }

    /**
     * 脂肪率
     *
     * @param activity   当前Activity
     * @param view       笑脸图标父级
     * @param imageView  笑脸图标
     * @param textView1  从左到右第一个分割线
     * @param textView2  从左到右第二个分割线
     * @param textView3  从左到右第三个分割线
     //* @param textView4  从左到右第四个分割线
     * @param bft_biaoz  是否标准
     * @param gender     性别0男，1女
     * @param age        年龄
     * @param fatPercent 当前人的脂肪率
     */
    public static void bft(Activity activity, View view, ImageView imageView, TextView textView1, TextView textView2,
                           TextView textView3, TextView bft_biaoz, int gender, int age, float fatPercent) {
        roundWidth = DisplayUtil.dip2px(activity, 15);
        roundWidth = roundWidth / 2;
        int margWidth = DisplayUtil.dip2px(activity, 10);
        LogUtils.d(TAG, "bft太阳的半径：" + roundWidth + "px");
        LogUtils.d(TAG, "bft margWidth：" + margWidth + "px");
        int d = DisplayUtil.dip2px(activity, 10f);
        int screenwidth = activity.getWindowManager().getDefaultDisplay().getWidth();
        int marg = DisplayUtil.dip2px(activity, 20f);
        screenwidth = screenwidth - marg;
        LogUtils.d(TAG, "bft屏幕宽度" + screenwidth);
        // 从左到右第一个分割线
        double critical_point1 = 0;
        // 从左到右第二个分割线
        double critical_point2 = 0;
        // 从左到右第三个分割线
        double critical_point3 = 0;
        // 从左到右第四个分割线
        //'double critical_point4 = 0;
        // 终点分割线
        double critical_point5 = 35;
        // 笑脸偏移量
        int deviation = 0;
        // 屏幕宽度

        if (gender == 1) {
            // 男
            if (age < 40) {
                /****偏瘦***/
                critical_point1 = 10;
                /****健康***/
                critical_point2 = 21;
                /****偏胖---胖***/
                critical_point3 = 26;
                ///critical_point4 = 26;
            } else if (age >= 40 && age < 60) {
                critical_point1 = 11;
                critical_point2 = 22;
                critical_point3 = 27;
                //critical_point4 = 27;
            } else if (age >= 60) {
                critical_point1 = 13;
                critical_point2 = 24;
                critical_point3 = 29;
                //critical_point4 = 29;
            }

        } else {
            // 女
            if (age < 40) {
                critical_point1 = 20;
                critical_point2 = 34;
                critical_point3 = 39;
                //critical_point4 = 39;
            } else if (age >= 40 && age < 60) {
                critical_point1 = 21;
                critical_point2 = 35;
                critical_point3 = 40;
                //critical_point4 = 40;
            } else if (age >= 60) {
                critical_point1 = 22;
                critical_point2 = 36;
                critical_point3 = 41;
                //critical_point4 = 41;
            }
        }
        if (fatPercent <= critical_point1) {
            deviation = (int) (screenwidth * 0.25 * (fatPercent / critical_point1));
            deviation = (deviation - roundWidth / 2);
            imageView.setImageDrawable(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.sunface));
            /***偏瘦***/
            bft_biaoz.setText(R.string.bar_pianshou_title);
            bft_biaoz.setBackground(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.green_light_color_bg));
        } else if (fatPercent > critical_point1 && fatPercent <= critical_point2) {
            //deviation = (int) (screenwidth * 0.2 + (fatPercent - critical_point1) / (critical_point2 - critical_point1) * screenwidth * 0.2);
            deviation = (int) (screenwidth * 0.25 + (fatPercent - critical_point1) / (critical_point2 - critical_point1) * screenwidth * 0.25);
            imageView.setImageDrawable(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.sunface));
            /***健康***/
            bft_biaoz.setText(R.string.bar_jiankang_title);
            bft_biaoz.setBackground(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.green_light_color_bg));
        } else if (fatPercent > critical_point2 && fatPercent <= critical_point3) {
            deviation = (int) (screenwidth * 0.5 + (fatPercent - critical_point2) / (critical_point3 - critical_point2) * screenwidth * 0.25);
            deviation = (deviation + roundWidth / 2);
            imageView.setImageDrawable(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.sunface));
            /***偏胖***/
            bft_biaoz.setText(R.string.bar_pianpang_title);
            bft_biaoz.setBackground(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.pianpang_bg));
            //deviation = (int) (screenwidth * 0.2 + (fatPercent - critical_point2) / (critical_point3 - critical_point2) * screenwidth * 0.2);
            //deviation = deviation + DisplayUtil.dip2px(activity, 9);
        } else if (fatPercent > critical_point3) {
            double ls = (screenwidth * 0.25) / (critical_point3 - critical_point2);
            deviation = (int) ((int) (screenwidth * 0.75) + (ls * (fatPercent - critical_point3)));
            //deviation = (int) (screenwidth * 0.75 + (fatPercent - critical_point3) / critical_point5 * screenwidth * 0.25);
            //deviation = (deviation + roundWidth / 2);
            imageView.setImageDrawable(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.sunface));
            /***胖***/
            bft_biaoz.setText(R.string.bar_pang_title);
            bft_biaoz.setBackground(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.red_color_bg));

        }

        textView1.setText(MyUtil.onePoint(critical_point1) + "%");

        textView2.setText(MyUtil.onePoint(critical_point2) + "%");

        textView3.setText(MyUtil.onePoint(critical_point3) + "%");
        //textView4.setText(MyUtil.onePoint(critical_point3) + "%");
        if (deviation > roundWidth) {
            deviation = (deviation - roundWidth);
        }
        if (fatPercent == 0) {
            deviation = 0;
        }
        if (deviation >= (screenwidth - roundWidth * 2)) {
            deviation = (screenwidth - roundWidth * 2);
        }
        //LogUtils.d(TAG, "fat彩条的左内边距：" + deviation);
        LogUtils.d(TAG, "fat彩条的左内边距" + deviation + "d:" + d);
        view.setPadding(deviation, 0, 0, 0);

         /*deviation = (int) (screenwidth * 0.6 + (fatPercent - critical_point4) / (critical_point4 - critical_point4) * screenwidth * 0.2);
            deviation = deviation + DisplayUtil.dip2px(activity, 11);*/
           /*else if (fatPercent > critical_point4) {
            imageView.setImageDrawable(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.sunface));
            deviation = (int) (screenwidth * 0.8 + (fatPercent - critical_point4) / critical_point5 * screenwidth * 0.2);
            deviation = deviation + DisplayUtil.dip2px(activity, 12);
            bft_biaoz.setText(R.string.bar_chaozhong_title);//超重
            bft_biaoz.setBackground(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.red_color_bg));
        }*/


        //textView4.setText(MyUtil.onePoint(critical_point4) + "%");

        /*if (deviation > roundWidth) {
            deviation = (deviation - roundWidth);
        }
        if (deviation >= (screenwidth - roundWidth * 2)) {
            deviation = (screenwidth - roundWidth * 2);
        }
        LogUtils.d(TAG, "BMI  deviation:" + deviation + "d:" + d);
        view.setPadding(deviation, 0, 0, 0);*/
    }

    public static String bftString(int gender, int age, float fatPercent,Context context) {
        MoveView.context=context;
        // 从左到右第一个分割线
        double critical_point1 = 0;
        // 从左到右第二个分割线
        double critical_point2 = 0;
        // 从左到右第三个分割线
        double critical_point3 = 0;
        // 从左到右第四个分割线
        double critical_point4 = 0;
        // 终点分割线
        double critical_point5 = 100;
        if (gender == 1) {
            // 男
            if (age < 40) {
                /****偏瘦***/
                critical_point1 = 10;
                /****健康***/
                critical_point2 = 21;
                /****偏胖---胖***/
                critical_point3 = 26;
                ///critical_point4 = 26;
            } else if (age >= 40 && age < 60) {
                critical_point1 = 11;
                critical_point2 = 22;
                critical_point3 = 27;
                //critical_point4 = 27;
            } else if (age >= 60) {
                critical_point1 = 13;
                critical_point2 = 24;
                critical_point3 = 29;
                //critical_point4 = 29;
            }

        } else {
            // 女
            if (age < 40) {
                critical_point1 = 20;
                critical_point2 = 34;
                critical_point3 = 39;
                //critical_point4 = 39;
            } else if (age >= 40 && age < 60) {
                critical_point1 = 21;
                critical_point2 = 35;
                critical_point3 = 40;
                //critical_point4 = 40;
            } else if (age >= 60) {
                critical_point1 = 22;
                critical_point2 = 36;
                critical_point3 = 41;
                //critical_point4 = 41;
            }
        }
        if (fatPercent <= critical_point1) {
            return context.getString(R.string.bar_pianshou_title);//偏瘦
        } else if (fatPercent > critical_point1 && fatPercent <= critical_point2) {
            return context.getString(R.string.bar_jiankang_title);//健康
        } else if (fatPercent > critical_point2 && fatPercent <= critical_point3) {
            return context.getString(R.string.bar_pianpang_title);//偏胖
        } else {
            return context.getString(R.string.bar_pang_title);//胖
        }
    }
        /*if (gender == 1) {
            // 男
            if (age < 40) {
                critical_point1 = 10;
                critical_point2 = 16;
                critical_point3 = 21;
                critical_point4 = 26;
            } else if (age >= 40 && age < 60) {
                critical_point1 = 11;
                critical_point2 = 17;
                critical_point3 = 22;
                critical_point4 = 27;
            } else if (age >= 60) {
                critical_point1 = 13;
                critical_point2 = 19;
                critical_point3 = 24;
                critical_point4 = 29;
            }

        } else {
            // 女
            if (age < 40) {
                critical_point1 = 20;
                critical_point2 = 27;
                critical_point3 = 34;
                critical_point4 = 39;
            } else if (age >= 40 && age < 60) {
                critical_point1 = 21;
                critical_point2 = 28;
                critical_point3 = 35;
                critical_point4 = 40;
            } else if (age >= 60) {
                critical_point1 = 22;
                critical_point2 = 29;
                critical_point3 = 36;
                critical_point4 = 41;
            }
        }*/

       /* if (fatPercent <= critical_point1) {
            return context.getString(R.string.bar_pianshou_title);//偏瘦
        } else if (fatPercent > critical_point1 && fatPercent <= critical_point2) {
            return context.getString(R.string.bar_jiankang_title);//健康
        } else if (fatPercent > critical_point2 && fatPercent <= critical_point3) {
            return context.getString(R.string.bar_pianpang_title);//偏胖
        } else if (fatPercent > critical_point3 && fatPercent <= critical_point4) {
            return context.getString(R.string.bar_pang_title);//胖
        } else {
            return context.getString(R.string.Overweight);//超重
        }*/

    public static int bftInt(int gender, int age, float fatPercent) {
        // 从左到右第一个分割线
        double critical_point1 = 0;
        // 从左到右第二个分割线
        double critical_point2 = 0;
        // 从左到右第三个分割线
        double critical_point3 = 0;
        // 从左到右第四个分割线
        double critical_point4 = 0;
        // 终点分割线
        double critical_point5 = 100;
        if (gender == 1) {
            // 男
            if (age < 40) {
                /****偏瘦***/
                critical_point1 = 10;
                /****健康***/
                critical_point2 = 21;
                /****偏胖---胖***/
                critical_point3 = 26;
                ///critical_point4 = 26;
            } else if (age >= 40 && age < 60) {
                critical_point1 = 11;
                critical_point2 = 22;
                critical_point3 = 27;
                //critical_point4 = 27;
            } else if (age >= 60) {
                critical_point1 = 13;
                critical_point2 = 24;
                critical_point3 = 29;
                //critical_point4 = 29;
            }

        } else {
            // 女
            if (age < 40) {
                critical_point1 = 20;
                critical_point2 = 34;
                critical_point3 = 39;
                //critical_point4 = 39;
            } else if (age >= 40 && age < 60) {
                critical_point1 = 21;
                critical_point2 = 35;
                critical_point3 = 40;
                //critical_point4 = 40;
            } else if (age >= 60) {
                critical_point1 = 22;
                critical_point2 = 36;
                critical_point3 = 41;
                //critical_point4 = 41;
            }
        }

        if (fatPercent <= critical_point1) {
            return 1;//偏瘦
        } else if (fatPercent <= critical_point2) {
            return 2;//健康
        } else if (fatPercent <= critical_point3) {
            return 3;//偏胖
        } else{
            return 4;//胖
        }
    }


    /**
     * 骨量
     *
     * @param activity  当前Activity
     * @param view      笑脸图标父级
     * @param imageView 笑脸图标
     * @param textView1 从左到右第一个分割线
     * @param textView2 从左到右第二个分割线
     * @param textView3 是否标准
     * @param bone      当前人的骨量
     */
    public static void bone(Activity activity, View view, ImageView imageView, TextView textView1, TextView textView2, TextView textView3, int gender, float weight, float bone, String danwei) {
        roundWidth = DisplayUtil.dip2px(activity, 15);
        roundWidth = (roundWidth / 2);
        int margWidth = DisplayUtil.dip2px(activity, 10);
        LogUtils.d(TAG, "太阳的半径：" + roundWidth + "px");
        LogUtils.d(TAG, "margWidth：" + margWidth + "px");
        int d = DisplayUtil.dip2px(activity, 10f);
        int screenwidth = activity.getWindowManager().getDefaultDisplay().getWidth();
        int marg = DisplayUtil.dip2px(activity, 20f);
        screenwidth = screenwidth - marg;
        LogUtils.d(TAG, "屏幕宽度" + screenwidth);

        // 从左到右第一个分割线
        float critical_point1 = 2.4f;
        // 从左到右第二个分割线
        float critical_point2 = 2.6f;
        // 终点分割线
        float critical_point3 = 3.2f;
        // 笑脸偏移量
        int deviation = 0;
        if (gender == 1) {
            // 男
            if (weight < 60) {
                critical_point1 = 2.4f;
                critical_point2 = 2.6f;
                critical_point3 = 3.2f;
            } else if (weight >= 60 && weight <= 75) {
                critical_point1 = 2.8f;
                critical_point2 = 3.0f;
                critical_point3 = 3.2f;
            } else if (weight > 75) {
                critical_point1 = 3.1f;
                critical_point2 = 3.3f;
                critical_point3 = 3.4f;
            }

        } else {
            // 女
            if (weight < 45) {
                critical_point1 = 1.7f;
                critical_point2 = 1.9f;
                critical_point3 = 2.5f;
            } else if (weight >= 45 && weight <= 60) {
                critical_point1 = 2.2f;
                critical_point2 = 2.3f;
                critical_point3 = 2.5f;
            } else if (weight > 60) {
                critical_point1 = 2.4f;
                critical_point2 = 2.6f;
                critical_point3 = 3.0f;
            }
        }

        if (bone <= critical_point1) {
            deviation = (int) (screenwidth * 0.25 * (bone / critical_point1));
            imageView.setImageDrawable(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.sunface));
            textView3.setText(R.string.bar_buzu_title);//不足
            textView3.setBackground(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.red_color_bg));
        } else if (bone > critical_point1 && bone <= critical_point2) {
            imageView.setImageDrawable(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.sunface));
            deviation = (int) (screenwidth * 0.25 + (bone - critical_point1) / (critical_point2 - critical_point1) * screenwidth * 0.5);
            textView3.setText(R.string.bar_biaozhun_title);//标准
            textView3.setBackground(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.green_light_color_bg));
        } else if (bone > critical_point2) {
            imageView.setImageDrawable(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.sunface));
            // deviation = (int) (screenwidth * 0.75 + (bone - critical_point2) / critical_point3 * screenwidth * 0.25);
            double ls = (screenwidth * 0.25) / (critical_point3 - critical_point2);
            deviation = (int) ((int) (screenwidth * 0.75) + (ls * (bone - critical_point2)));
            textView3.setText(R.string.bar_you_title);//优
            textView3.setBackground(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.grade_bg));
        }
        if (danwei.equals(UtilConstants.UNIT_LB) || danwei.equals(UtilConstants.UNIT_FATLB) || danwei.equals(UtilConstants.UNIT_ST)) {
            textView1.setText(UtilTooth.kgToLB_ForFatScale(critical_point1) + "lb");
            textView2.setText(UtilTooth.kgToLB_ForFatScale(critical_point2) + "lb");
        } else {
            textView1.setText(MyUtil.onePoint(critical_point1) + "kg");
            textView2.setText(MyUtil.onePoint(critical_point2) + "kg");
        }
        if (deviation > roundWidth) {
            deviation = (deviation - roundWidth);
        }
        if (deviation >= (screenwidth - roundWidth * 2)) {
            deviation = (screenwidth - roundWidth * 2);
        }
        LogUtils.d(TAG, "deviation:" + deviation + "d:" + d);
        view.setPadding(deviation, 0, 0, 0);
    }

    public static String boneString(int gender, float weight, float bone,Context context) {
        MoveView.context=context;
        // 从左到右第一个分割线
        float critical_point1 = 2.4f;
        // 从左到右第二个分割线
        float critical_point2 = 2.6f;
        // 终点分割线
        float critical_point3 = 3.2f;
        // 笑脸偏移量
        int deviation = 0;
        if (gender == 1) {
            // 男
            if (weight < 60) {
                critical_point1 = 2.4f;
                critical_point2 = 2.6f;
                critical_point3 = 3.2f;
            } else if (weight >= 60 && weight <= 75) {
                critical_point1 = 2.8f;
                critical_point2 = 3.0f;
                critical_point3 = 3.2f;
            } else if (weight > 75) {
                critical_point1 = 3.1f;
                critical_point2 = 3.3f;
                critical_point3 = 3.4f;
            }

        } else {
            // 女
            if (weight < 45) {
                critical_point1 = 1.7f;
                critical_point2 = 1.9f;
                critical_point3 = 2.5f;
            } else if (weight >= 45 && weight <= 60) {
                critical_point1 = 2.1f;
                critical_point2 = 2.3f;
                critical_point3 = 2.5f;
            } else if (weight > 60) {
                critical_point1 = 2.4f;
                critical_point2 = 2.6f;
                critical_point3 = 3.0f;
            }
        }
        // 屏幕宽度

        if (bone <= critical_point1) {
            return context.getString(R.string.bar_buzu_title);//不足
        } else if (bone > critical_point1 && bone <= critical_point2) {
            return context.getString(R.string.bar_biaozhun_title);//标准
        } else {
            return context.getString(R.string.bar_you_title);//优
        }

    }


    public static int boneInt(int gender, float weight, float bone) {
        // 从左到右第一个分割线
        float critical_point1 = 2.4f;
        // 从左到右第二个分割线
        float critical_point2 = 2.6f;
        // 终点分割线
        float critical_point3 = 3.2f;
        // 笑脸偏移量
        int deviation = 0;
        if (gender == 1) {
            // 男
            if (weight < 60) {
                critical_point1 = 2.4f;
                critical_point2 = 2.6f;
                critical_point3 = 3.2f;
            } else if (weight >= 60 && weight <= 75) {
                critical_point1 = 2.8f;
                critical_point2 = 3.0f;
                critical_point3 = 3.2f;
            } else if (weight > 75) {
                critical_point1 = 3.1f;
                critical_point2 = 3.3f;
                critical_point3 = 3.4f;
            }

        } else {
            // 女
            if (weight < 45) {
                critical_point1 = 1.7f;
                critical_point2 = 1.9f;
                critical_point3 = 2.5f;
            } else if (weight >= 45 && weight <= 60) {
                critical_point1 = 2.1f;
                critical_point2 = 2.3f;
                critical_point3 = 2.5f;
            } else if (weight > 60) {
                critical_point1 = 2.4f;
                critical_point2 = 2.6f;
                critical_point3 = 3.0f;
            }
        }
        // 屏幕宽度

        if (bone <= critical_point1) {
            return 1;//不足
        } else if (bone > critical_point1 && bone <= critical_point2) {
            return 2;//标准
        } else {
            return 3;//优
        }

    }


    /**
     * BMI
     *
     * @param activity  当前Activity
     * @param view      笑脸图标父级
     * @param imageView 笑脸图标
     * @param textView1 从左到右第一个分割线
     * @param textView2 从左到右第二个分割线
     * @param textView3 从左到右第三个分割线
     * @param bft_biaoz 是否标准
     * @param bmi       当前人的BMI值
     */
    public static void bmi(Activity activity, View view, ImageView imageView, TextView textView1, TextView textView2, TextView textView3, TextView bft_biaoz, float bmi) {
        roundWidth = DisplayUtil.dip2px(activity, 15);
        roundWidth = (roundWidth / 2);
        int margWidth = DisplayUtil.dip2px(activity, 10);
        LogUtils.d(TAG, "太阳的半径：" + roundWidth + "px");
        LogUtils.d(TAG, "margWidth：" + margWidth + "px");
        int d = DisplayUtil.dip2px(activity, 10f);
        int screenwidth = activity.getWindowManager().getDefaultDisplay().getWidth();
        int marg = DisplayUtil.dip2px(activity, 20f);
        screenwidth = screenwidth - marg;
        LogUtils.d(TAG, "屏幕宽度" + screenwidth);

        // 从左到右第一个分割线
        double critical_point1 = 18.5;
        // 从左到右第二个分割线
        double critical_point2 = 24.0;
        // 从左到右第三个分割线
        double critical_point3 = 30.0;
        // 终点分割线
        double critical_point5 = 35;
        // 笑脸偏移量
        int deviation = 0;
        // 屏幕宽度

        if (bmi < critical_point1) {
            deviation = (int) (screenwidth * 0.25 * (bmi / critical_point1));
            deviation = (deviation - roundWidth / 2);
            imageView.setImageDrawable(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.sunface));
            bft_biaoz.setText(R.string.bar_pianshou_title);//偏瘦
            bft_biaoz.setBackground(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.green_light_color_bg));
        } else if (bmi >= critical_point1 && bmi < critical_point2) {
            imageView.setImageDrawable(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.sunface));
            deviation = (int) (screenwidth * 0.25 + (bmi - critical_point1) / (critical_point2 - critical_point1) * screenwidth * 0.25);
            bft_biaoz.setText(R.string.bar_biaozhun_title);//标准"
            bft_biaoz.setBackground(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.grade_bg));
        } else if (bmi >= critical_point2 && bmi < critical_point3) {
            imageView.setImageDrawable(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.sunface));
            deviation = (int) (screenwidth * 0.5 + (bmi - critical_point2) / (critical_point3 - critical_point2) * screenwidth * 0.25);
            deviation = (deviation + roundWidth / 2);
            bft_biaoz.setText(R.string.bar_pianpang_title);//偏胖
            bft_biaoz.setBackground(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.red_color_bg));
        } else if (bmi >= critical_point3) {
            imageView.setImageDrawable(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.sunface));
            deviation = (int) (screenwidth * 0.75 + (bmi - critical_point3) / critical_point5 * screenwidth * 0.25);
            deviation = (deviation + roundWidth / 2);
            bft_biaoz.setText(R.string.bar_pang_title);//胖
            bft_biaoz.setBackground(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.red_color_bg));
        }
        textView1.setText(MyUtil.onePoint(critical_point1) + "");
        textView2.setText(MyUtil.onePoint(critical_point2) + "");
        textView3.setText(MyUtil.onePoint(critical_point3) + "");

        if (deviation > roundWidth) {
            deviation = (deviation - roundWidth);
        }
        if (deviation >= (screenwidth - roundWidth * 2)) {
            deviation = (screenwidth - roundWidth * 2);
        }
        LogUtils.d(TAG, "BMI  deviation:" + deviation + "d:" + d);
        view.setPadding(deviation, 0, 0, 0);
    }


    /**
     * BMI
     *
     * @param activity  当前Activity
     * @param view      笑脸图标父级
     * @param imageView 笑脸图标
     * @param textView1 从左到右第一个分割线
     * @param textView2 从左到右第二个分割线
     * @param textView3 从左到右第三个分割线
     * @param bft_biaoz 是否标准
     * @param bmi       当前人的BMI值
     */
    public static void bmibaby(Activity activity, View view, ImageView imageView, TextView textView1, TextView textView2, TextView textView3, TextView bft_biaoz, float bmi) {
        // 从左到右第一个分割线
        double critical_point1 = 15;
        // 从左到右第二个分割线
        double critical_point2 = 18;
        // 从左到右第三个分割线
        double critical_point3 = 22;
        // 终点分割线
        double critical_point5 = 26;
        // 笑脸偏移量
        float deviation = 0;
        // 屏幕宽度
        int screenwidth = activity.getWindowManager().getDefaultDisplay().getWidth();
        LogUtils.i("MoveView", "屏幕的宽度:" + screenwidth);
        if (bmi <= critical_point1) {
            deviation = (float) (screenwidth * 0.25 * (bmi / critical_point1));
            imageView.setImageDrawable(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.sunface));
            bft_biaoz.setText(R.string.bar_pianshou_title);//偏瘦
            bft_biaoz.setBackground(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.green_light_color_bg));
        } else if (bmi > critical_point1 && bmi <= critical_point2) {
            imageView.setImageDrawable(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.sunface));
            deviation = (int) (screenwidth * 0.25 + (bmi - critical_point1) / (critical_point2 - critical_point1) * screenwidth * 0.25);
            bft_biaoz.setText(R.string.bar_biaozhun_title);//标准"
            bft_biaoz.setBackground(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.grade_bg));
        } else if (bmi > critical_point2 && bmi <= critical_point3) {
            imageView.setImageDrawable(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.sunface));
            deviation = (int) (screenwidth * 0.5 + (bmi - critical_point2) / (critical_point3 - critical_point2) * screenwidth * 0.25);
            bft_biaoz.setText(R.string.bar_pianpang_title);//偏胖
            bft_biaoz.setBackground(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.red_color_bg));
        } else if (bmi > critical_point3) {
            imageView.setImageDrawable(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.sunface));
            deviation = (int) (screenwidth * 0.75 + (bmi - critical_point3) / critical_point5 * screenwidth * 0.25) + 80;
            LogUtils.i("Move", "左边距：" + deviation);
            bft_biaoz.setText(R.string.bar_pang_title);//胖
            bft_biaoz.setBackground(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.red_color_bg));
        }
        textView1.setText(MyUtil.onePoint(critical_point1) + "");
        textView2.setText(MyUtil.onePoint(critical_point2) + "");
        textView3.setText(MyUtil.onePoint(critical_point3) + "");
        float margin = 0;
        if (bmi != 0) {
            margin = deviation + 80;
            if (margin > screenwidth - 125) {
                margin = screenwidth - 125;
            }
        }

        view.setPadding((int) margin, 0, 0, 0);
    }

    /**
     * BMI相关的标准计算
     *
     * @param bmi
     * @return
     */
    public static String bmiString(float bmi ,Context context) {
        MoveView.context=context;
        // 从左到右第一个分割线
        double critical_point1 = 18.5;
        // 从左到右第二个分割线
        double critical_point2 = 24.0;
        // 从左到右第三个分割线
        double critical_point3 = 30.0;
        // 终点分割线
        double critical_point5 = 22;


        if (bmi < critical_point1) {
            return context.getString(R.string.bar_pianshou_title);//偏瘦
        } else if (bmi >= critical_point1 && bmi < critical_point2) {
            return context.getString(R.string.bar_biaozhun_title);//标准
        } else if (bmi >= critical_point2 && bmi < critical_point3) {
            return context.getString(R.string.bar_pianpang_title);//偏胖
        } else {
            return context.getString(R.string.bar_pang_title);//胖
        }
    }

    public static String babybmiString(float bmi) {
        // 从左到右第一个分割线
        double critical_point1 = 15;
        // 从左到右第二个分割线
        double critical_point2 = 18;
        // 从左到右第三个分割线
        double critical_point3 = 22;
        // 终点分割线
        double critical_point5 = 26;
        if (bmi <= critical_point1) {
            return context.getString(R.string.bar_pianshou_title);//偏瘦
        } else if (bmi > critical_point1 && bmi <= critical_point2) {
            return context.getString(R.string.bar_biaozhun_title);//标准
        } else if (bmi > critical_point2 && bmi <= critical_point3) {
            return context.getString(R.string.bar_pianpang_title);//偏胖
        } else {
            return context.getString(R.string.bar_pang_title);//胖
        }
    }


    /**
     * 内脏脂肪指数
     *
     * @param activity
     * @param view
     * @param imageView
     * @param textView1
     * @param textView2
     * @param textView3
     * @param visceral
     */
    public static void visceralFat(Activity activity, View view, ImageView imageView, TextView textView1, TextView textView2, TextView textView3, float visceral) {
        roundWidth = DisplayUtil.dip2px(activity, 15);
        roundWidth = (roundWidth / 2);
        int margWidth = DisplayUtil.dip2px(activity, 10);
        LogUtils.d(TAG, "太阳的半径：" + roundWidth + "px");
        LogUtils.d(TAG, "margWidth：" + margWidth + "px");
        int d = DisplayUtil.dip2px(activity, 10f);
        int screenwidth = activity.getWindowManager().getDefaultDisplay().getWidth();
        int marg = DisplayUtil.dip2px(activity, 20f);
        screenwidth = screenwidth - marg;
        LogUtils.d(TAG, "屏幕宽度" + screenwidth);

        // 从左到右第一个分割线
        double critical_point1 = 9.0;
        // 从左到右第二个分割线
        double critical_point2 = 14.0;
        // 终点分割线
        double critical_point3 = 16;
        // 笑脸偏移量
        int deviation = 0;
        // 屏幕宽度

        if (visceral <= critical_point1) {
            deviation = (int) (screenwidth * 0.25 * (visceral / critical_point1));
            imageView.setImageDrawable(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.sunface));
            textView3.setText(R.string.bar_biaozhun_title);//标准
            textView3.setBackground(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.grade_bg));
        } else if (visceral > critical_point1 && visceral <= critical_point2) {
            imageView.setImageDrawable(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.sunface));
            deviation = (int) (screenwidth * 0.25 + (visceral - critical_point1) / (critical_point2 - critical_point1) * screenwidth * 0.5);
            textView3.setText(R.string.bar_jinti_title);//警惕
            textView3.setBackground(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.orange_bg));
        } else if (visceral > critical_point2) {
            imageView.setImageDrawable(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.sunface));
            double ls = (screenwidth * 0.25) / (critical_point3 - critical_point2);
            deviation = (int) ((int) (screenwidth * 0.75) + (ls * (visceral - critical_point2)));
            textView3.setText(R.string.bar_weixian_title);//危险
            textView3.setBackground(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.red_color_bg));
        }
        textView1.setText(MyUtil.onePoint(critical_point1) + "");
        textView2.setText(MyUtil.onePoint(critical_point2) + "");
        if (deviation > roundWidth) {
            deviation = (deviation - roundWidth);
        }
        if (deviation >= (screenwidth - roundWidth * 2)) {
            deviation = (screenwidth - roundWidth * 2);
        }
        LogUtils.d(TAG, "deviation:" + deviation + "d:" + d);
        view.setPadding(deviation, 0, 0, 0);
    }

    /**
     * 内脏指肪相关
     *
     * @param vis
     * @return
     */
    public static String visceralFatString(float vis,Context context) {
        MoveView.context=context;
        // 从左到右第一个分割线
        double critical_point1 = 9.0;
        // 从左到右第二个分割线
        double critical_point2 = 14.0;

        if (vis <= critical_point1) {
            return context.getString(R.string.bar_biaozhun_title);//标准
        } else if (vis > critical_point1 && vis <= critical_point2) {
            return context.getString(R.string.bar_jinti_title);//警惕
        } else {
            return context.getString(R.string.bar_weixian_title);//危险
        }
    }

    /**
     * 内脏脂肪标准的计算
     *
     * @param visceralfat
     * @return
     */
    public static int visceralFatInt(float visceralfat) {
        // 从左到右第一个分割线
        double critical_point1 = 9.0;
        // 从左到右第二个分割线
        double critical_point2 = 14.0;
        // 终点分割线
        double critical_point3 = 16;

        if (visceralfat <= critical_point1) {
            return 1;//标准
        } else if (visceralfat > critical_point1 && visceralfat <= critical_point2) {
            return 2;//警惕
        } else {
            return 3;//危险
        }
    }

    /**
     * BMR基础代谢率
     *
     * @param activity  当前Activity
     * @param view      笑脸图标父级
     * @param imageView 笑脸图标
     * @param textView1 从左到右第一个分割线
     * @param textView3 是否标准
     * @param bmr       当前人的BMr值
     */
    public static void bmr(Activity activity, View view, ImageView imageView, TextView textView1, TextView textView3, int gender, int age, float weight, float bmr) {
        roundWidth = DisplayUtil.dip2px(activity, 15);
        roundWidth = (roundWidth / 2);
        int margWidth = DisplayUtil.dip2px(activity, 10);
        LogUtils.d(TAG, "太阳的半径：" + roundWidth + "px");
        LogUtils.d(TAG, "margWidth：" + margWidth + "px");
        int d = DisplayUtil.dip2px(activity, 10f);
        int screenwidth = activity.getWindowManager().getDefaultDisplay().getWidth();
        LogUtils.d(TAG, "屏幕宽度" + screenwidth);

        // 从左到右第一个分割线
        float critical_point1 = 1261;
        // 终点分割线
        float critical_point3 = 1261;
        // 笑脸偏移量
        int deviation = 0;
        // 屏幕宽度

        if (age <= 29) {
            if (gender == 1) {
                critical_point1 = UtilTooth.keep1Point3(weight * 24.0f);
                critical_point3 = critical_point1;
            } else {
                critical_point1 = UtilTooth.keep1Point3(weight * 23.6f);
                critical_point3 = critical_point1;
            }
        } else if (age >= 30 && age <= 49) {
            if (gender == 1) {
                critical_point1 = UtilTooth.keep1Point3(weight * 22.3f);
                critical_point3 = critical_point1;
            } else {
                critical_point1 = UtilTooth.keep1Point3(weight * 21.7f);
                critical_point3 = critical_point1;
            }
        } else {
            if (gender == 1) {
                critical_point1 = UtilTooth.keep1Point3(weight * 21.5f);
                critical_point3 = critical_point1;
            } else {
                critical_point1 = UtilTooth.keep1Point3(weight * 20.7f);
                critical_point3 = critical_point1;
            }
        }

        LogUtils.d(TAG, "BMR:" + critical_point1);

        if (bmr <= critical_point1) {
            deviation = (int) (screenwidth * 0.5 * (bmr / critical_point1));
            imageView.setImageDrawable(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.sunface));
            textView3.setText(R.string.bar_piandi_title);//偏低
            textView3.setBackground(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.red_color_bg));
        } else if (bmr > critical_point1) {
            imageView.setImageDrawable(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.sunface));
            deviation = (int) (screenwidth * 0.5 + (bmr - critical_point1) / critical_point3 * screenwidth * 0.5);
            textView3.setText(R.string.bar_you_title);//优
            textView3.setBackground(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.grade_bg));
        }
        textView1.setText(MyUtil.onePoint(critical_point1) + "Kcal");
        if (deviation > roundWidth) {
            deviation = (deviation - roundWidth);
        }
        if (deviation >= (screenwidth - roundWidth * 2)) {
            deviation = (screenwidth - roundWidth * 2);
        }
        LogUtils.d(TAG, "BMR  deviation:" + deviation + "d:" + d);
        view.setPadding(deviation, 0, 0, 0);
    }

    public static String bmrString(int gender, int age, float weight, float bmr,Context context) {
        MoveView.context=context;
        // 从左到右第一个分割线
        float critical_point1 = 1261;
        // 终点分割线
        float critical_point3 = 1261;

        if (age <= 29) {
            if (gender == 1) {
                critical_point1 = UtilTooth.keep1Point3(weight * 24.0f);
                critical_point3 = critical_point1;
            } else {
                critical_point1 = UtilTooth.keep1Point3(weight * 23.6f);
                critical_point3 = critical_point1;
            }
        } else if (age >= 30 && age <= 49) {
            if (gender == 1) {
                critical_point1 = UtilTooth.keep1Point3(weight * 22.3f);
                critical_point3 = critical_point1;
            } else {
                critical_point1 = UtilTooth.keep1Point3(weight * 21.7f);
                critical_point3 = critical_point1;
            }
        } else {
            if (gender == 1) {
                critical_point1 = UtilTooth.keep1Point3(weight * 21.5f);
                critical_point3 = critical_point1;
            } else {
                critical_point1 = UtilTooth.keep1Point3(weight * 20.7f);
                critical_point3 = critical_point1;
            }
        }

        if (bmr <= critical_point1) {
            return context.getString(R.string.bar_piandi_title);//偏低
        } else {
            return context.getString(R.string.bar_you_title);//优
        }
    }

    public static float bmrBiaoZhunFloat(int gender, int age, float weight, float bmr) {
        // 从左到右第一个分割线
        float critical_point1 = 1261;
        // 终点分割线
        float critical_point3 = 1261;

        if (age <= 29) {
            if (gender == 1) {
                critical_point1 = UtilTooth.keep1Point3(weight * 24.0f);
                critical_point3 = critical_point1;
            } else {
                critical_point1 = UtilTooth.keep1Point3(weight * 23.6f);
                critical_point3 = critical_point1;
            }
        } else if (age >= 30 && age <= 49) {
            if (gender == 1) {
                critical_point1 = UtilTooth.keep1Point3(weight * 22.3f);
                critical_point3 = critical_point1;
            } else {
                critical_point1 = UtilTooth.keep1Point3(weight * 21.7f);
                critical_point3 = critical_point1;
            }
        } else {
            if (gender == 1) {
                critical_point1 = UtilTooth.keep1Point3(weight * 21.5f);
                critical_point3 = critical_point1;
            } else {
                critical_point1 = UtilTooth.keep1Point3(weight * 20.7f);
                critical_point3 = critical_point1;
            }
        }

        return critical_point1;
    }

    public static int bmrInt(int gender, int age, float weight, float bmr) {
        // 从左到右第一个分割线
        float critical_point1 = 1261;
        // 终点分割线
        float critical_point3 = 1261;

        if (age <= 29) {
            if (gender == 1) {
                critical_point1 = UtilTooth.keep1Point3(weight * 24.0f);
                critical_point3 = critical_point1;
            } else {
                critical_point1 = UtilTooth.keep1Point3(weight * 23.6f);
                critical_point3 = critical_point1;
            }
        } else if (age >= 30 && age <= 49) {
            if (gender == 1) {
                critical_point1 = UtilTooth.keep1Point3(weight * 22.3f);
                critical_point3 = critical_point1;
            } else {
                critical_point1 = UtilTooth.keep1Point3(weight * 21.7f);
                critical_point3 = critical_point1;
            }
        } else {
            if (gender == 1) {
                critical_point1 = UtilTooth.keep1Point3(weight * 21.5f);
                critical_point3 = critical_point1;
            } else {
                critical_point1 = UtilTooth.keep1Point3(weight * 20.7f);
                critical_point3 = critical_point1;
            }
        }

        if (bmr <= critical_point1) {
            return 1;//偏低
        } else {
            return 3;//优
        }
    }

    public static void muscle(Activity activity, View view, ImageView imageView, TextView textView1, TextView textView2, TextView textView3, int gender, float height, float muscle, String danwei) {
        roundWidth = DisplayUtil.dip2px(activity, 15);
        roundWidth = (roundWidth / 2);
        int margWidth = DisplayUtil.dip2px(activity, 10);
        LogUtils.d(TAG, "太阳的半径：" + roundWidth + "px");
        LogUtils.d(TAG, "margWidth：" + margWidth + "px");
        int d = DisplayUtil.dip2px(activity, 10f);
        int screenwidth = activity.getWindowManager().getDefaultDisplay().getWidth();
        int marg = DisplayUtil.dip2px(activity, 20f);
        screenwidth = screenwidth - marg;
        LogUtils.d(TAG, "屏幕宽度" + screenwidth);
        // 从左到右第一个分割线
        float critical_point1 = 1;
        // 从左到右第二个分割线
        float critical_point2 = 1;
        // 终点分割线
        float critical_point3 = 20;
        // 笑脸偏移量
        int deviation = 0;
        // 屏幕宽度
        if (gender == 1) {
            // 男
            if (height < 160) {
                critical_point1 = 38.5f;
                critical_point2 = 46.5f;
                //critical_point3 = 21;

            } else if (height >= 160 && height <= 170) {
                critical_point1 = 44f;
                critical_point2 = 52.4f;
                //critical_point3 = 22;

            } else {
                critical_point1 = 49.4f;
                critical_point2 = 59.4f;
                // critical_point3 = 24;

            }

        } else {
            // 女
            if (height < 150) {
                critical_point1 = 29.1f;
                critical_point2 = 34.7f;
                //critical_point3 = 21;

            } else if (height >= 150 && height <= 160) {
                critical_point1 = 32.9f;
                critical_point2 = 37.5f;
                // critical_point3 = 22;

            } else {
                critical_point1 = 36.5f;
                critical_point2 = 42.5f;
                //critical_point3 = 24;

            }
        }

        if (muscle <= critical_point1) {
            deviation = (int) (screenwidth * 0.25 * (muscle / critical_point1));
            imageView.setImageDrawable(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.sunface));
            textView3.setText(R.string.bar_buzu_title);//不足
            textView3.setBackground(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.red_color_bg));
        } else if (muscle > critical_point1 && muscle <= critical_point2) {
            imageView.setImageDrawable(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.sunface));
            deviation = (int) (screenwidth * 0.25 + (muscle - critical_point1) / (critical_point2 - critical_point1) * screenwidth * 0.5);
            textView3.setText(R.string.bar_biaozhun_title);//标准
            textView3.setBackground(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.green_light_color_bg));
        } else if (muscle > critical_point2) {
            imageView.setImageDrawable(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.sunface));
            deviation = (int) (screenwidth * 0.75 + (muscle - critical_point2) / critical_point3 * screenwidth * 0.25);
            textView3.setText(R.string.bar_you_title);//优
            textView3.setBackground(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.grade_bg));
        }
        if (danwei.equals(UtilConstants.UNIT_LB) || danwei.equals(UtilConstants.UNIT_FATLB) || danwei.equals(UtilConstants.UNIT_ST)) {
            textView1.setText(UtilTooth.kgToLB_ForFatScale(critical_point1) + "lb");
            textView2.setText(UtilTooth.kgToLB_ForFatScale(critical_point2) + "lb");
        } else {
            textView1.setText(MyUtil.onePoint(critical_point1) + "kg");
            textView2.setText(MyUtil.onePoint(critical_point2) + "kg");
        }
        if (deviation > roundWidth) {
            deviation = (deviation - roundWidth);
        }
        if (deviation >= (screenwidth - roundWidth * 2)) {
            deviation = (screenwidth - roundWidth * 2);
        }
        LogUtils.d(TAG, "deviation:" + deviation + "d:" + d);
        view.setPadding(deviation, 0, 0, 0);
    }

    /**
     * 肌肉相关标准计算
     *
     * @param gender
     * @param height
     * @param muscle
     * @return
     */
    public static String muscleString(int gender, float height, float muscle ,Context context) {
        MoveView.context=context;
        // 从左到右第一个分割线
        float critical_point1 = 1;
        // 从左到右第二个分割线
        float critical_point2 = 1;
        // 终点分割线
        float critical_point3 = 20;
        if (gender == 1) {
            // 男
            if (height < 160) {
                critical_point1 = 38.5f;
                critical_point2 = 46.5f;
                //critical_point3 = 21;

            } else if (height >= 160 && height <= 170) {
                critical_point1 = 44f;
                critical_point2 = 52.4f;
                //critical_point3 = 22;

            } else {
                critical_point1 = 49.4f;
                critical_point2 = 59.4f;
                // critical_point3 = 24;

            }

        } else {
            // 女
            if (height < 150) {
                critical_point1 = 29.1f;
                critical_point2 = 34.7f;
                //critical_point3 = 21;

            } else if (height >= 150 && height <= 160) {
                critical_point1 = 32.9f;
                critical_point2 = 37.5f;
                // critical_point3 = 22;

            } else {
                critical_point1 = 36.5f;
                critical_point2 = 42.5f;
                //critical_point3 = 24;

            }
        }

        if (muscle <= critical_point1) {
            return context.getString(R.string.bar_buzu_title);//不足
        } else if (muscle > critical_point1 && muscle <= critical_point2) {
            return context.getString(R.string.bar_biaozhun_title);//标准
        } else {
            return context.getString(R.string.bar_you_title);//优
        }

    }

    public static int muscleInt(int gender, float height, float muscle) {
        // 从左到右第一个分割线
        float critical_point1 = 1;
        // 从左到右第二个分割线
        float critical_point2 = 1;
        // 终点分割线
        float critical_point3 = 20;
        if (gender == 1) {
            // 男
            if (height < 160) {
                critical_point1 = 38.5f;
                critical_point2 = 46.5f;
                //critical_point3 = 21;

            } else if (height >= 160 && height <= 170) {
                critical_point1 = 44f;
                critical_point2 = 52.4f;
                //critical_point3 = 22;

            } else {
                critical_point1 = 49.4f;
                critical_point2 = 59.4f;
                // critical_point3 = 24;

            }

        } else {
            // 女
            if (height < 150) {
                critical_point1 = 29.1f;
                critical_point2 = 34.7f;
                //critical_point3 = 21;

            } else if (height >= 150 && height <= 160) {
                critical_point1 = 32.9f;
                critical_point2 = 37.5f;
                // critical_point3 = 22;

            } else {
                critical_point1 = 36.5f;
                critical_point2 = 42.5f;
                //critical_point3 = 24;

            }
        }

        if (muscle <= critical_point1) {
            return 1;//不足
        } else if (muscle > critical_point1 && muscle <= critical_point2) {
            return 2;//标准
        } else {
            return 3;//优
        }

    }

    public static void physicAge(Activity activity, View view, TextView textView1, TextView textView2, TextView textView3, float age, int physicage) {
        LogUtils.i("MoveView", "age1:" + age);
        LogUtils.i("MoveView", "age2:" + physicage);
        roundWidth = DisplayUtil.dip2px(activity, 15);
        roundWidth = (roundWidth / 2);
        int margWidth = DisplayUtil.dip2px(activity, 20);
        LogUtils.d(TAG, "太阳的半径：" + roundWidth + "px");
        LogUtils.d(TAG, "margWidth：" + margWidth + "px");
        int d = DisplayUtil.dip2px(activity, 10f);
        int screenwidth = activity.getWindowManager().getDefaultDisplay().getWidth();
        screenwidth = screenwidth - margWidth;
        LogUtils.d(TAG, "屏幕宽度" + screenwidth);
        // 从左到右第一个分割线
        float critical_point1 = 1;

        // 笑脸偏移量
        int deviation = 0;
        // 屏幕宽度
        LogUtils.d("MoveView", "屏幕宽度:" + screenwidth);
        critical_point1 = age;//设置的年龄

        textView1.setText((int) age + "");
        textView2.setText(physicage + "");//测试出的年龄
        if (physicage <= critical_point1) {
            deviation = (int) (screenwidth / (age * 2) * physicage);
            LogUtils.d("MoveView", "笑脸偏移量:" + deviation);

            textView3.setText(R.string.bar_you_title);//优
            textView3.setBackground(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.grade_bg));
        } else {
            deviation = (int) (screenwidth / (age * 2) * physicage);
            LogUtils.d("MoveView", "笑脸偏移量:" + deviation);
            textView3.setText(R.string.bar_piangao_title);//偏高
            textView3.setBackground(ContextCompat.getDrawable(activity.getApplicationContext(), R.drawable.red_color_bg));
        }
        if (deviation > roundWidth) {
            deviation = (deviation - roundWidth);
        }
        if (deviation >= (screenwidth - roundWidth * 2)) {
            deviation = (screenwidth - roundWidth * 2);
        }
        LogUtils.d(TAG, "deviation:" + deviation + "d:" + d);
        view.setPadding(deviation, 0, 0, 0);
    }

}
